﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class UMacKeepConfigEdit : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.修改 };
            }
        }
        protected override string DWZRef
        {
            get { return "UMacKeepConfigList"; }
        }

        #region
        /// <summary>
        /// 需要修改的ID
        /// </summary>
        protected int UMKCID
        {
            get
            {
                return GetRequestValue<int>("UMKCID");
            }
        }

        private UMacKeepConfigInfo _obj;
        protected UMacKeepConfigInfo obj
        {
            get
            {
                if (_obj == null)
                {
                    List<UMacKeepConfigInfo> lis = UMacKeepController.UMacKeepConfig_GetALL();
                    _obj=lis.First(e => e.UMKCID == UMKCID);
                   // _obj = UMacKeepController.UMacKeepConfig_GetALL(ID);
                }
                return _obj;
                //OMenuController.ge
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "edit")
            {
                addmenu();
            }

        }

        protected void addmenu()
        {
            UMacKeepConfigInfo obx =Request.SerializableObject<UMacKeepConfigInfo>();

            AddLog(Permission.修改,obj, obx);

            if (UMacKeepController.UMacKeepConfig_Update(obx))
            {
                SuccessJson("修改成功", DWZRef);
            }
            else
                ErrorJson("修改失败", DWZRef);
        }


        protected string GetSMSTempleteList(string key)
        {
            string litemp = "<option value=\"{0}\" {1}>{0}</option>";
            string listr = "";
            List<USMSTempleteInfo> dt = USMSTempleteController.GetAll();
            foreach (USMSTempleteInfo dr in dt)
            {

                listr += string.Format(litemp, dr.Tkey, dr.Tkey == key ? "selected" : "");
            }
            return listr;
        }
    }
}